import java.util.Scanner;

public class demo03 {
    public static int count=0;
    public static int[] di={0,1,0,-1};
    public static int[] dj={1,0,-1,0};
    public static void main(String[] args) {
//        玩具蛇
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                int[][] arr=new int[4][4];
                int len=2;
                arr[i][j]=1;
                dfs(arr,i,j,len);
            }
        }
        System.out.println(count);
    }
    public static void dfs(int[][] arr,int i,int j,int len){
        if(arr[i][j]==16){
            count++;
            return;
        }
        for (int k = 0; k < 4; k++) {
            int i1=i+di[k];
            int j1=j+dj[k];
            if(i1>=0&&i1<4&&j1>=0&&j1<4&&arr[i1][j1]==0){
                arr[i1][j1]=len;
                dfs(arr,i1,j1,len+1);
                arr[i1][j1]=0;
            }
        }
    }
}
